package com.lottery.material.service.portal.circle.impl;

import com.lottery.material.dao.circle.CircleInfoMapper;
import com.lottery.material.dao.circle.CircleRuleConfigMapper;
import com.lottery.material.pojo.circle.CircleInfo;
import com.lottery.material.pojo.circle.CircleRuleConfig;
import com.lottery.material.pojo.page.Page;
import com.lottery.material.pojo.page.PageData;
import com.lottery.material.service.portal.circle.CircleInfoService;
import com.lottery.material.util.Const;
import com.lottery.material.vo.portal.circle.CircleInfoVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author:houjie
 * @Description: 圈子接口实现类
 * @Date:Create in 2019/4/9 15:17
 */
@Service
@Slf4j
public class CircleInfoServiceImpl implements CircleInfoService {

    @Autowired
    private CircleInfoMapper circleInfoMapper;

    @Override
    public CircleInfo findById(Integer id) {
        return circleInfoMapper.selectByPrimaryKey(id);
    }

    /**
     * description: 根据圈子id查询上架的圈子
     * author sunny
     * createDate 2019-04-25 下午 3:29
     * @param circleId
     * @return
     */
    @Override
    public CircleInfo findByCircleId(String circleId) {
        return circleInfoMapper.findByCircleId(circleId);
    }

    /**
     * @Author 肖拔赟
     * @Description 圈子名称模糊搜索
     * @Date Created on 2019-04-22 17:24
     */
    @Override
    public List<CircleInfoVo> findByCircleNameLike(String circleName) {
        return circleInfoMapper.findByCircleNameLike(circleName);
    }


    /**
     * @Author 肖拔赟
     * @Description 获取圈子成员
     * @Date Created on 2019-04-22 17:2
     * @param circleId 圈子Id
     * @param queryType 查询类型（1：全部；2：禁言用户；3：未验证用户）
     */
    @Override
    public void getCircleUser(String circleId, String queryType){

    }

    /**
     * @Author 肖拔赟
     * @Description 获取圈子成员
     * @Date Created on 2019-04-22 17:2
     * @param menuCode 所属主类型级别编号
     * @param userId userId
     */
    @Override
    public List<CircleInfoVo> getCircleByMenuCode(String menuCode, String userId) {
        return circleInfoMapper.getCircleByMenuCode(menuCode, userId);
    }


    /**
     * @Author 肖拔赟
     * @Description 5.5	获取圈子成员
     * @Date Created on 2019-04-22 17:2
     * @param circleId 圈子Id
     * @param queryType 查询类型（1：全部；2：禁言用户；3：未验证用户）
     */
    @Override
    public List<Map<String,String>> getMemberUserListPage(String circleId, String queryType,
                                                          int currentPage){
        PageData pageData = new PageData();
        pageData.put("circleId", circleId);
        if("3".equals(queryType)){
            pageData.put("rank", "1");
        }else if("2".equals(queryType)){
            pageData.put("isBan", "2");
        }

        Page page = new Page();
        page.setPd(pageData);
        page.setShowCount(Const.PORTAL_PAGE);
        page.setCurrentPage(currentPage);

        return circleInfoMapper.getMemberUserListPage(page);

    }

    /**
     * description: 查询热门圈子
     * author sunny
     * createDate 2019-05-15 上午 10:25
     * @return
     * @throws Exception
     */
    @Override
    public List<Map<String, Object>> findHotCircle() throws Exception {
        return circleInfoMapper.findHotCircle();
    }
}
